define([], function () {
    var app = angular.module("App.home");
    app.controller("projects.detail.propertiesCtrl", ["$scope", "$http", "curPrj", 'corporationList', function ($scope, $http, curPrj, corporationList) {
        $scope.states = ["桩基施工", "开挖", "报警", "新增", "地下结构", "地上结构", "后期跟踪", "停工", "已完成", "已归档", "其他"];
        $scope.tunnelTypes = ["单圆隧道", "双圆隧道", "大圆", "车站", "明挖", "高架", "其他"];
        $scope.levels = ["特级", "一级", "二级", "三级"];
        $scope.owners = corporationList;
        $scope.curPrj = curPrj;
        $scope.corpChange = function () {
            $scope.constructionCorpItem = corporationList.filter(function (item) {
                return item.shortName === curPrj.constructionCorp;
            })[0];
        };

        $scope.$watch("curPrj.constructionCorp", function () {
            $scope.corpChange();
        }, true);

        $scope.corpChange();
        $scope.item = {
            status: curPrj.status === 1 ? true : false
        };
        $scope.submit = function () {
            $scope.status = "uploading";
            curPrj.status = $scope.item.status ? 1 : 0;
            curPrj
                .postProperties()
                .then(function () {
                    $scope.status = "succeeded";
                }, function () {
                    $scope.status = "failed";
                });
        };
    }]);
});
